<template>
  <div>
    <!-- 列表组件 -->
    <ul>
      <li v-for="(item, index) in list" :key="index">
        <span>{{item.name}}</span>
        <span>{{item.phone}}</span>
        <button>拨号</button>
        <button @click="edit(index)">编辑</button>
        <button @click="del(index)">删除</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: ['list'],
  methods: {
    edit(index) {
      // 子传父，传一个联系人信息的对象过去，一步到位
      this.list[index].index = index
      this.$emit('edit', this.list[index]);
    },
    del(index) {
      this.$emit('del', index);
    }
  }
}
</script>

<style>

</style>